package com.mathdroid.model.simulation;

/**
 * This utility class is used to convert stats into other stats.
 */
public final class StatConverter {
	
	/**
	 * Hide the default constructor.
	 */
	private StatConverter() { }
	
	/**
	 * This coefficient increases the damage bonus from the primary stats
	 * Strength, Willpower, Cunning and Aim.
	 */
	private static final double PRIMARYSTAT_BONUSDAMAGE_COEFFICIENT = 0.2;
	
	/**
	 * This coefficient increases Bonus Damage from Tech Power and 
	 * Force Power.
	 */
	private static final double TF_POWER_BONUSDAMAGE_COEFFICIENT = 0.23;
	
	/**
	 * This coefficient increases Bonus Healing from Tech Power and 
	 * Force Power.
	 */
	private static final double TF_POWER_BONUSHEALING_COEFFICIENT = 0.17;
	
	/**
	 * This coefficient increases Bonus Damage from Power.
	 */
	private static final double POWER_BONUSDAMAGE_COEFFICIENT = 0.23;
	
	/**
	 * This coefficient increases Bonus Healing from Power.
	 */
	private static final double POWER_BONUSHEALING_COEFFICIENT = 0.18;
	
	/**
	 * This coefficient increases Health from Endurance.
	 */
	private static final double ENDURANCE_HEALTH_COEFFICIENT = 10d;
	
	/**
	 * This coefficient increases the Health Regen from Endurance.
	 */
	private static final double HEALTH_REGEN_COEFFICIENT = 0.03;
	
	/**
	 * This coefficient increases the Companion Bonus Health from Presence.
	 */
	private static final double COMPANION_BONUSHEALTH_COEFFICIENT = 5d;
	
	/**
	 * This coefficient increases the Companion Bonus Damage from Presence.
	 */
	private static final double COMPANION_BONUSDAMAGE_COEFFICIENT = 0.2d;
	
	/**
	 * This coefficient increases the Companion Bonus Healing from Presence.
	 */
	private static final double COMPANION_BONUSHEALING_COEFFICIENT = 0.14d;

	/**
	 * Get the melee damage bonus from the Strength stat.
	 * @param str Strength value.
	 * @return Melee damage bonus.
	 */
	static double getMeleeDamageBonus(final int str) {
		return str * PRIMARYSTAT_BONUSDAMAGE_COEFFICIENT;
	}
	
	/**
	 * Get the technological damage bonus from the Cunning stat.
	 * @param cun Cunning value.
	 * @return Technological damage bonus.
	 */
	static double getTechnologicalDamageBonus(final int cun) {
		return cun * PRIMARYSTAT_BONUSDAMAGE_COEFFICIENT;
	}
	
	/**
	 * Get the ranged damage bonus from the Aim stat.
	 * @param aim Aim value.
	 * @return Ranged damage bonus.
	 */
	static double getRangedDamageBonus(final int aim) {
		return aim * PRIMARYSTAT_BONUSDAMAGE_COEFFICIENT;
	}
	
	/**
	 * Get the force damage bonus from the Willpower stat.
	 * @param wil Willpower value.
	 * @return Force damage bonus.
	 */
	static double getForceDamageBonus(final int wil) {
		return wil * PRIMARYSTAT_BONUSDAMAGE_COEFFICIENT;
	}
	
	/**
	 * Get the Tech Bonus Damage from the Tech Power stat.
	 * @param tp Tech Power.
	 * @return Tech Bonus Damage.
	 */
	static double getTechBonusDamageFromTechPower(final int tp) {
		return tp * TF_POWER_BONUSDAMAGE_COEFFICIENT;
	}
	
	/**
	 * Get the Force Bonus Damage from the Force Power stat.
	 * @param fp Force Power.
	 * @return Force Bonus Damage.
	 */
	static double getForceBonusDamageFromForcePower(final int fp) {
		return fp * TF_POWER_BONUSDAMAGE_COEFFICIENT;
	}
	
	/**
	 * Get the Tech Bonus Healing from the Tech Power stat.
	 * @param tp Tech Power.
	 * @return Tech Bonus Healing.
	 */
	static double getTechBonusHealingFromTechPower(final int tp) {
		return tp * TF_POWER_BONUSHEALING_COEFFICIENT;
	}
	
	/**
	 * Get the Force Bonus Healing from the Force Power stat.
	 * @param fp Force Power.
	 * @return Force Bonus Healing.
	 */
	static double getForceBonusHealingFromForcePower(final int fp) {
		return fp * TF_POWER_BONUSHEALING_COEFFICIENT;
	}
	
	/**
	 * Get the Tech&Force Bonus Damage from the Power stat.
	 * @param p Power.
	 * @return Tech&Force Bonus Damage.
	 */
	static double getBonusDamageFromPower(final int p) {
		return p * POWER_BONUSDAMAGE_COEFFICIENT;
	}
	
	/**
	 * Get the Tech&Force Bonus Healing from the Power stat.
	 * @param p Power.
	 * @return Tech&Force Bonus Healing.
	 */
	static double getBonusHealingFromPower(final int p) {
		return p * POWER_BONUSHEALING_COEFFICIENT;
	}
	
	/**
	 * Get the Health increase from the Endurance stat.
	 * @param end Endurance.
	 * @return Health.
	 */
	static double getHealthFromEndurance(final int end) {
		return end * ENDURANCE_HEALTH_COEFFICIENT;
	}
	
	/**
	 * Get the Health Regen from the Endurance stat.
	 * @param end Endurance.
	 * @return Health Regen.
	 */
	static double getHealthRegenFromEndurance(final int end) {
		return end * HEALTH_REGEN_COEFFICIENT;
	}
	
	/**
	 * Get the Companion Bonus Health from the Presence stat.
	 * @param p Presence.
	 * @return Companion Bonus Health.
	 */
	static double getCompanionBonusHealthFromPresence(final int p) {
		return p * COMPANION_BONUSHEALTH_COEFFICIENT;
	}
	
	/**
	 * Get the Companion Bonus Damage from the Presence stat.
	 * @param p Presence.
	 * @return Companion Bonus Damage.
	 */
	static double getCompanionBonusDamageFromPresence(final int p) {
		return p * COMPANION_BONUSDAMAGE_COEFFICIENT;
	}
	
	/**
	 * Get the Companion Bonus Healing from the Presence stat.
	 * @param p Presence.
	 * @return Companion Bonus Healing.
	 */
	static double getCompanionBonusHealingFromPresence(final int p) {
		return p * COMPANION_BONUSHEALING_COEFFICIENT;
	}
}
